package com.blockmeta.bbs.minemodule.pojo;

import android.text.TextUtils;

import com.blockmeta.bbs.minemodule.fragment.BaseMyActiveListFragment;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * @author AirThor
 * @date 2019/12/24.
 */
public class MyActiveListPOJO implements BaseMyActiveListFragment.HasMoreData{

    /**
     * total : 4
     * list : [{"tid":398468,"applyid":23340,"title":"玲听2020跨年演讲","image":"https://appserversrc.8btc.com/activity/20191211112555_BihM.jpeg","starttime":1577442600,"endtime":1577460600,"place":"浙江省杭州市运河文化艺术中心","ticket_name":"免费","ticket_cost":0},{"tid":394990,"applyid":23157,"title":"链趋势·创未来: 2019\u201c领航华中\u201d创新区块链企业家年会","image":"https://appserversrc.8btc.com/activity/20191125164133_vw9h.jpeg","starttime":1577494800,"endtime":1577534400,"place":"湖北省武汉市会展中心","ticket_name":"观众免费票","ticket_cost":0},{"tid":374070,"applyid":21708,"title":"上海区块链周最值得去的活动：9月18日IOSG老友记上海Meetup","image":"https://appserversrc.8btc.com/activity/20190907121243_WOF1.jpeg","starttime":1568799000,"endtime":1568813400,"place":"上海市上海市杨浦区外滩LAVIN玫瑰里宴会中心","ticket_name":"免费票","ticket_cost":0},{"tid":157875,"applyid":8039,"title":"新金融100人 | 金融业如何迎接区块链革命？[北京]","image":"data/attachment/forum/201804/16/114205kky284nydpf88f8h.png","starttime":1524805200,"endtime":1524822300,"place":"北京市东城区法华寺街91号","ticket_name":null,"ticket_cost":0}]
     */

    @SerializedName("total")
    public int total;
    @SerializedName("list")
    public List<ListBean> list;

    @Override
    public boolean hasMoreData() {
        return list!=null&&list.size()!=0;
    }

    public static class ListBean implements IMyActiveListPOJO{
        public final static int NORMAL = 0;

        @Override
        public String getTid() {
            return String.valueOf(tid);
        }

        @Override
        public String getApplyId() {
            return String.valueOf(applyid);
        }

        @Override
        public String getTitle() {
            return title;
        }

        @Override
        public String getTicketName() {
            return TextUtils.isEmpty(ticketName)?"":ticketName;
        }

        @Override
        public String getAttachUrl() {
            return TextUtils.isEmpty(image)?"-":image;
        }

        @Override
        public long getStartTimeFrom() {
            return TextUtils.isEmpty(starttime)?0:Long.parseLong(starttime);
        }

        @Override
        public long getStartTimeTo() {
            return TextUtils.isEmpty(endtime)?0:Long.parseLong(endtime);
        }

        @Override
        public boolean iSActiveOverdue() {
            long currentTime = System.currentTimeMillis()/1000;
            return currentTime > getStartTimeTo();
        }

        @Override
        public String getPlace() {
            return place;
        }

        @Override
        public String getPrice() {
            return ticketCost;
        }

        @Override
        public int getItemType() {
            return NORMAL;
        }

        @Override
        public String getCode() {
            return code;
        }

        /**
         * tid : 398468
         * applyid : 23340
         * title : 玲听2020跨年演讲
         * image : https://appserversrc.8btc.com/activity/20191211112555_BihM.jpeg
         * starttime : 1577442600
         * endtime : 1577460600
         * place : 浙江省杭州市运河文化艺术中心
         * ticket_name : 免费
         * ticket_cost : 0
         */

        @SerializedName("tid")
        public int tid;
        @SerializedName("applyid")
        public int applyid;
        @SerializedName("title")
        public String title;
        @SerializedName("image")
        public String image;
        @SerializedName("starttime")
        public String starttime;
        @SerializedName("endtime")
        public String endtime;
        @SerializedName("place")
        public String place;
        @SerializedName("ticket_name")
        public String ticketName;
        @SerializedName("ticket_cost")
        public String ticketCost;
        @SerializedName("code")
        public String code;
    }
}
